﻿#pragma once
#include <QObject>
#include <PluginObject.h>

class AbstruactEventMediator;
class AttributeGroup;

class QmlEventGroup: public Plugin
{
	using this_type = QmlEventGroup;
	using event_func = std::function<void(QJsonObject const& obj)>;
	Q_OBJECT
public:
	using Plugin::Plugin;
	virtual ~QmlEventGroup() = default;
	QStringView name() const override;
	bool load(QString const& cfgFile = QString()) override;
	void logsEvent(QJsonObject const& logsObj) override;
	void sensorsEvent(QJsonObject const& valuesObj) override;
	QStringList subTopic() const override;
	void handleMessage(QStringView topic, QByteArray payload) override;
	QStringList commands() const override;
private slots:
	void onMessage(QJsonObject const& msg);
private:
	void updateData(QJsonObject const& obj);
private:
	AttributeGroup* m_ag = nullptr;
};

